package leetcode100;

import java.lang.reflect.Array;
import java.util.Arrays;

public class lc044 {
    public static void main(String[] args) {
        int[] nums = new int[] {0,1,2,0,2,0,1,1};
        new lc044().sortColors(nums);
    }

    public void sortColors(int[] nums) {
        int countRed = 0;
        int countWhite = 0;
        int countBlue=0;

        for (int num : nums) {
            if (num==0) {
                countRed++;
            } else if(num==1) {
                countWhite++;
            } else {
                countBlue++;
            }
        }

        Arrays.fill(nums,2);
        Arrays.fill(nums,0,countRed,0);
        Arrays.fill(nums,countRed,countRed+countWhite,1);

        System.out.println(Arrays.toString(nums));
    }
}
